package behavioral.templateMethod.custom;

/**
 * 饮料
 */
public abstract class Beverage {

    public void make() {
        this.wash();
        this.peeled();
        this.diced();
        this.addExcipients();
        this.smash();
        if (needCondiments()) {
            this.addCondiments();
        }
    }

    /**
     * 钩子函数
     * @return
     */
    protected boolean needCondiments() {
        return true;
    }

    protected void wash() {
        System.out.println("清洗");
    }

    protected void peeled() {
        System.out.println("剥皮");
    }

    protected void diced() {
        System.out.println("切块");
    }

    protected void smash() {
        System.out.println("打碎");
    }

    /**
     * 添加辅料
     */
    protected void addExcipients() {
        System.out.println("加水");
    }

    /**
     * 添加主料
     */
    protected abstract void addGoods();

    /**
     * 添加调味品
     */
    protected abstract void addCondiments();

}
